package com.singleton.gsj20150511;

//在多线程不能工作
public class LazySingleton {
	private static LazySingleton instance;
	
	private LazySingleton(){}
	
	public static LazySingleton getInstance(){
		if(instance == null){
			instance = new LazySingleton();
		}
		return instance;
	}
}

//线程安全
class LazySafeSingleton {
	private static LazySafeSingleton instance;
	
	private LazySafeSingleton(){}
	
	public static synchronized LazySafeSingleton getInstance(){
		if(instance == null){
			instance = new LazySafeSingleton();
		}
		return instance;
	}
}